﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace HamsterDocs.EntityFrameworkCore.Sqlite.Extensions;

public static class ServiceExtensions
{
    public static IServiceCollection AddSqliteDbContext(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDbContext<IContext, SqliteDbContext>(options =>
        {
            options.UseSqlite(configuration.GetConnectionString("DefaultConnection"));
            
#if DEBUG
            options.EnableSensitiveDataLogging();
#endif
        });
        
        return services;
    }
}